from socket import *

serverSocket = socket(AF_INET, SOCK_STREAM)
serverSocket.bind(("", 8899))

print("listen ready")
serverSocket.listen(5)
print("listen sucess")
print("accept ready")

# 接收成功后就返回一个新的客服端，以及连接方的IP和port
clientSokcet, clientInfo = serverSocket.accept()
print("accept ready")
# 接收到的为客户端发送的数据
while True:
    print("recv ready")
    recvData = clientSokcet.recv(1024)
    print("recv sucess")
    print(clientInfo)
    print(recvData.decode('gb2312'))
# recvContent, recvAddr = recvData
# print("From--> {} Message:{}".format(recvAddr, recvContent))

clientSokcet.close()
serverSocket.close()